package com.tlp.tlp2k11;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class PhotoCapture extends Activity implements OnClickListener {
	
    private static final int REQUEST_ACTION_IMAGE_CAPTURE = 1;

	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.photo);
        
        Button button = (Button) findViewById(R.id.button);
        button.setOnClickListener(this);
    }
    
	public void onClick(View v) {
		Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, REQUEST_ACTION_IMAGE_CAPTURE);
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (requestCode == REQUEST_ACTION_IMAGE_CAPTURE) {
			Bitmap bitmap = (Bitmap)data.getExtras().get("data");
			ImageView image = (ImageView)findViewById(R.id.ImageView);
			image.setImageBitmap(bitmap);
		}
		
		super.onActivityResult(requestCode, resultCode, data);
	}
    
}
